package com.example.boot.listener;

import lombok.extern.log4j.Log4j;
import lombok.extern.log4j.Log4j2;
import org.springframework.boot.context.event.ApplicationStartedEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

/**
 * spring boot实现org.springframework.boot.context.event包下的接口完成监听;
 * 需要配置当前实现类为系统component; 也可以在resources/META-INF/spring.factories中配置：
 * org.springframework.context.ApplicationListener=package1.package2.实现类
 * 实现激活;
 */
@Component
@Log4j2
public class StartedListener implements ApplicationListener<ApplicationStartedEvent> {
    public void onApplicationEvent(ApplicationStartedEvent event) {
        log.info("info: {}    ", "ApplicationStartedEvent");
    }
}
